package com.frxuexi.park2302.notice

import com.frxuexi.lib_base.http.ApiService
import com.frxuexi.lib_base.mvi.BaseViewModel
import com.frxuexi.lib_base.mvi.RequestType
import dagger.hilt.android.lifecycle.HiltViewModel
import javax.inject.Inject

@HiltViewModel
class NoticeViewModel @Inject constructor(val apiService: ApiService):BaseViewModel<NoticeIntent>() {
    override fun handlerIntent(it: NoticeIntent) {
        when(it){
            is NoticeIntent.getNotice->{
//                httpRequest(apiService.getNotices(it.page,it.size))
                pagingRequest ({
                    NoticeDataSource(apiService)
                })
            }
            is NoticeIntent.deleteNotice->{
//                httpRequest(apiService.getNotices(),RequestType.DELETE)
            }
            is NoticeIntent.addNotice->{
                httpRequest(apiService.addNotice(toBody(it.item)))
            }


            else -> {}
        }
    }


}